Don't loop endlessly on malformed tpo3 file.
authorrobertl <robertl>
Mon, 20 Apr 2009 17:42:59 +0000 (17:42 +0000)
committerrobertl <robertl>
Mon, 20 Apr 2009 17:42:59 +0000 (17:42 +0000)
tpo.c

diff --git a/tpo.c b/tpo.c
index 372ab86dde15378af841c243c4c7956a2498b15c..45a6491b2511fc4b34f5278108baa5ba6df6895d 100644 (file)
--- a/tpo.c
+++ b/tpo.c
@@ -210,7 +210,9 @@ tpo_read_until_section(const char* section_name, int seek_bytes)
        int header_size = 0;
 
        while (1) {
-               gbfread(&byte, 1, 1, tpo_file_in);
+               if (gbfread(&byte, 1, 1, tpo_file_in) < 1) {
+                  fatal(MYNAME ": malformed input file - attempt to read past end");
+                }
                header_size++;
 
                if (byte == section_name[match_index]) {
@@ -1856,4 +1858,3 @@ ff_vecs_t tpo3_vecs = {
        tpo3_args,
        CET_CHARSET_ASCII, 0    /* CET-REVIEW */
 };
-